<?php


namespace App\Models;

/**
 * 城市-模型
 * @author aaron
 * @since 2020/11/11
 * Class CityModel
 * @package App\Models
 */
class CityModel extends BaseModel
{
    // 设置数据表
    protected $table = 'city';

    protected $fillable = [
        'pid',
        'level',
        'name',
        'citycode',
    ];

    public function scopeByCityCode($query, $code)
    {
        return $query->where('citycode', $code);
    }

    public function scopeByName($query, $name)
    {
        return $query->where('name', "like", "%{$name}%");
    }

    public function scopeByPid($query, $pid)
    {
        return $query->where('pid', $pid);
    }
}
